#pragma once

#include "Singleton.h"

#include <vector>
#include <boost/asio.hpp>

class AsioIOServicePool : public Singleton<AsioIOServicePool>
{
	friend class Singleton<AsioIOServicePool>;
	using Work = boost::asio::io_context::work;
	using WorkPtr = std::unique_ptr<Work>;

public:
	~AsioIOServicePool();
	
	boost::asio::io_context& getIOService();
	void stop();

private:
	AsioIOServicePool(size_t size = std::thread::hardware_concurrency() );

private:
	size_t m_nextIOService;
	std::vector<boost::asio::io_context> m_ioServices;
	std::vector<WorkPtr> m_works;
	std::vector<std::thread> m_threads;
};

